import { getCates } from '../../service/category';

Page({
  data: {
    catesList: []
  },
  onLoad() {
    const Cates = wx.getStorageSync('cates');
    if (!Cates || Date.now() - Cates.time > 1000*60*5) {
      this.pageInit();
    }else {
      this.setData({
        catesList: Cates.data
      })
    }

  },
  pageInit: async function () {
    let cates = await getCates();

    this.setData({
      catesList: cates.data.message
    })
    wx.setStorageSync('cates', {
      time: Date.now(),
      data: cates.data.message
    });
      
  }
})